#!/bin/bash
#========================================================================
# Author: YSLin
# Email: 
# File Name: mytar.sh
# Description: 
#  Using $0
#   This variable is commonly used to determine the behavior of scripts that can be
# 	invoked with more than one name.

#	You can use this script to list the contents of a tar file (t as in tape and ar as in archive, a common format for
#	distributing files in UNIX) or to create a tar file based on the name with which the script is invoked. The tar
#	file to read or create is specified as the first argument, $1.
#   
#   
# Edit History: 
#   2010-12-22    File created.
#========================================================================
case ´basename $0´ in
	*listtar) 
		TARGS="-tvf $1" ;;
	*maketar) 
		TARGS="-cvf $1.tar $1" ;;
	*) echo "Usage: $0 [file|directory]"
		exit 0
		;;
esac
tar $TARGS

ln -s mytar.sh listtar
ln -s mytar.sh maketar

#$ ls fruits
#apple banana mango peach pear

#$ ./maketar fruits
#$ ./listtar fruits.tar
#rwxr-xr-x 500/100 0 Nov 17 08:48 1998 fruits/
#rw-r--r-- 500/100 0 Nov 17 08:48 1998 fruits/apple
#rw-r--r-- 500/100 0 Nov 17 08:48 1998 fruits/banana
#rw-r--r-- 500/100 0 Nov 17 08:48 1998 fruits/mango
#rw-r--r-- 500/100 0 Nov 17 08:48 1998 fruits/pear
#rw-r--r-- 500/100 0 Nov 17 08:48 1998 fruits/peach


